
(*
print_endline "Begin.";;
Subprocess.run_blocking "python silly.py"
  (fun p -> print_endline ("PID: " ^ (string_of_int p)))
  (fun l -> print_endline ("STDOUT: " ^ l))
  (fun l -> print_endline ("STDERR: " ^ l))
  (fun s -> print_endline ("EXIT_STATUS: " ^
			     (Subprocess.string_of_status s)));;
*)

let runner = new Subprocess.runner in
  runner#set_start_cb
    (fun p -> print_endline ("PID: " ^ (string_of_int p)));
  runner#set_stdout_cb
    (fun l -> print_endline ("STDOUT: " ^ l));
  runner#set_stderr_cb
    (fun l -> print_endline ("STDERR: " ^ l));
  runner#set_stop_cb
    (fun s -> print_endline ("EXIT_STATUS: " ^
			       (Subprocess.string_of_status s)));
  runner#init();
  Thread.delay 2.0;
  runner#run "ls /home/tdl";
  Thread.delay 2.0;
  runner#run "python silly.py";
  Thread.delay 2.0;
  runner#kill ();
  Thread.delay 2.0;
  runner#run "ls /home/tdl";
  Thread.delay 2.0;
  runner#deinit();;
